//
//  UIImag+Extension.swift
//  SinWEiBo
//
//  Created by 胡良志 on 2018/4/17.
//  Copyright © 2018年 HuLiangZhi. All rights reserved.
//

import UIKit


extension UIImage{
    
    /// 截取当前屏幕
    class func snapShopCurrentWindow() -> UIImage{
        let window = UIApplication.shared.keyWindow!
        //开启图片上下文
        UIGraphicsBeginImageContext(window.frame.size)
        //将当前的window绘制到图形上下文中
        window.drawHierarchy(in: window.frame, afterScreenUpdates: true)
        //从图形上下文中获取图片
        let image = UIGraphicsGetImageFromCurrentImageContext()
        //关闭图形上下文
        UIGraphicsEndImageContext()
        return image!
    }
}



